/************************************************************************
    filename:   DaterEvent.cpp
    created:    15/4/2012
    author:     4Ys

    purpose:    Implements abstract base class for Event objects
*************************************************************************/

#include "DaterEvent.h"

namespace Dater
{
	//----------------------------------------------------------------------------//
	Event::Event(const std::string& type, const std::string& name,const Time& startTime,
		const Time& finishTime, const std::string& description, unsigned int userID,
		unsigned int eventID): _type(type), _allDay(false)
	{
		_name = name;
		_startTime = startTime;
		_finishTime = finishTime;
		_description = description;
		_userID = userID;
		_createTime.setTime();
		_eventID = eventID;

		_reminding = 0;
		_repeating = 0;
	}

	//----------------------------------------------------------------------------//
	Event::~Event()
	{
		delete _reminding;
	}

	//----------------------------------------------------------------------------//
	void Event::setName(const std::string& name)
	{
		_name = name;
	}

	//----------------------------------------------------------------------------//
	void Event::setStartTime(const Time& startTime)
	{
		_startTime = startTime;
	}

	//----------------------------------------------------------------------------//
	void Event::setFinishTime(const Time& finishTime)
	{
		if(finishTime.getTimeDiffer(_startTime) <= 0)
		{}//exception
		_finishTime = finishTime;
	}

	void Event::setCreateTime(const Time& createTime)
	{
		_createTime = createTime;
	}

	//----------------------------------------------------------------------------//
	void Event::setDescription(const std::string& description)
	{
		_description = description;
	}

	//----------------------------------------------------------------------------//
	void Event::setReminding(int remindTime, std::string remindUnit)
	{
		if(!_reminding)
			_reminding = new Reminding(remindTime, remindUnit);
		else
		{
			_reminding ->setRemindTime(remindTime);
			_reminding ->setRemindUnit(remindUnit);
		}
	}

	void Event::setRepeating(int repeatInterval, std::string repeatUnit, Time repeatEndTime)
	{
		if(!_repeating)
			_repeating = new Repeating(repeatInterval, repeatUnit, repeatEndTime);
		else
		{
			_repeating->setRepeatEndTime(repeatEndTime);
			_repeating->setRepeatInterval(repeatInterval);
			_repeating->setRepeatUnit(repeatUnit);
		}
	}

	//----------------------------------------------------------------------------//
	const std::string& Event::getType()
	{
		return _type;
	}

	//----------------------------------------------------------------------------//
	std::string& Event::getName()
	{
		return _name;
	}

	//----------------------------------------------------------------------------//
	Time& Event::getStartTime()
	{
		return _startTime;
	}

	//----------------------------------------------------------------------------//
	Time& Event::getFinishTime()
	{
		return _finishTime;
	}

	//----------------------------------------------------------------------------//
	Time& Event::getCreateTime()
	{
		return _createTime;
	}

	//----------------------------------------------------------------------------//
	std::string& Event::getDescription()
	{
		return _description;
	}

	//----------------------------------------------------------------------------//
	Reminding* Event::getReminding()
	{
		return _reminding;
	}

	Repeating* Event::getRepeating()
	{
		return _repeating;
	}

	//----------------------------------------------------------------------------//
	unsigned int Event::getEventID()
	{
		return _eventID;
	}

	//----------------------------------------------------------------------------//
	unsigned int Event::getUserID()
	{
		return _userID;
	}

	//----------------------------------------------------------------------------//

	const std::string& Event::getTagColor()
	{
		return _tagColor;
	}

	void Event::setAllDay(bool setting)
	{
		_allDay = setting;
	}

	bool Event::isAllDay()
	{
		return _allDay;
	}

	bool Event::isAllDayOfOneDay(int year, int month, int day)
	{
		/*int startYear = _startTime.getTime()->tm_year + 1900;
		int startMonth = _startTime.getTime()->tm_mon + 1;
		int startDay = _startTime.getTime()->tm_mday;

		int finishYear = _finishTime.getTime()->tm_year + 1900;
		int finishMonth = _finishTime.getTime()->tm_mon + 1;
		int finishDay = _finishTime.getTime()->tm_mday;

		if(_allDay)
		{
			if(
		}else
		{
		}*/
		return true;
	}
}